import { RouteRecordRaw } from 'vue-router';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    component: () => import('@/layout/index.vue'),
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'Home',
      component: () => import('@/views/home/index.vue'),
      meta: {
        title: '首页',
      }
    },
    {
      path: 'catelist',
      name: 'CateList',
      component: () => import('@/views/cateList/index.vue'),
      meta: {
        title: '分类',
      }
    },
    {
      path: 'topic',
      name: 'Topic',
      component: () => import('@/views/topic/index.vue'),
      meta: {
        title: '值得买',
      }
    },
    {
      path: 'shopcar',
      name: 'Shopcar',
      component: () => import('@/views/cart/index.vue'),
      meta: {
        title: '购物车',
      }
    }, {
      path: 'center',
      name: 'Center',
      component: () => import('@/views/center/index.vue'),
      meta: {
        title: '个人',
      }
    }
    ]
  },
  // 不需要layout布局的页面
  {
    path: '/search',
    name: 'Search',
    component: () => import('@/views/search/index.vue'),
    meta: {
      title: '搜索',
    }
  },
  {
    path: '/detail',
    name: 'Detail',
    component: () => import('@/views/detail/index.vue'),
    meta: {
      title: '详情',
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: '登录',
    }
  },
  {
    path: '/order',
    name: 'Order',
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: '订单',
    }
  },

  // 替代vue2中的'*'通配符路径
  { path: '/:pathMatch(.*)*', redirect: '/' },
];

export default routes